/**
 * 
 */
package run;


import java.io.File;
import java.util.Iterator;
import java.util.Vector;




//import org.xtext.MaDslStandaloneSetup;
/*import org.xtext.maDsl.EFFECTIFS;
import org.xtext.maDsl.MODALITES;
import org.xtext.maDsl.PROGRAMME;
import org.xtext.maDsl.REEL;
import org.xtext.maDsl.RETURN;
*/
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.xtext.LtsStandaloneSetupGenerated;
import org.xtext.lts.Statemachine;

/**
 * @author D.Abdelali
 *
 */
public class LtsRunner {


    
    public static Statemachine ParseLtsProgram(String uri){

    	new LtsStandaloneSetupGenerated().createInjectorAndDoEMFRegistration();
        ResourceSet resourceSet = new ResourceSetImpl();
        
        File profileUrl = new File(uri);
        java.net.URI javaURI = profileUrl.toURI();
        URI emfURI = URI.createURI(javaURI.toString());
        
        //Resource resource = resourceSet.getResource(URI.createURI(uri,true),true);
        Resource resource = resourceSet.getResource(emfURI,true);
        
        
        EObject eobject = resource.getContents().get(0); // récupération de la racine de l'arbre syntaxique du programme
        
        Statemachine ltsProgramme = (Statemachine) eobject;
               
        return ltsProgramme;
    }
    
    public static void main(String[] args){
    	
    	Statemachine st = ParseLtsProgram("D:\\runtime-Eclipseapplication\\essai\\features\\Automate\\root.lts");
    	
    	//Statemachine st = ParseLtsProgram("src/test.lts");
    	
    	String result = st.getEvents().get(0).getName();
    	System.out.println(result);
    	
    }

}
